widget-factory: Make the sliding opt-in
authorMatthias Clasen <mclasen@redhat.com>
Sun, 28 Feb 2016 04:12:15 +0000 (23:12 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 28 Feb 2016 04:12:15 +0000 (23:12 -0500)
The sliding is a little disorienting, so turn it off by default
and add a checkbutton for it in the gear menu.

demos/widget-factory/widget-factory.c
demos/widget-factory/widget-factory.ui

index baa7c430407641f92b02e8629e798e2c882a3cdc..087c34e00f683512402f7f0c10360c929aa59224 100644 (file)
@@ -38,6 +38,25 @@ change_theme_state (GSimpleAction *action,
   g_simple_action_set_state (action, state);
 }
 
+static GtkWidget *page_stack;
+
+static void
+change_transition_state (GSimpleAction *action,
+                         GVariant      *state,
+                         gpointer       user_data)
+{
+  GtkStackTransitionType transition;
+
+  if (g_variant_get_boolean (state))
+    transition = GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT;
+  else
+    transition = GTK_STACK_TRANSITION_TYPE_NONE;
+
+  gtk_stack_set_transition_type (GTK_STACK (page_stack), transition);
+
+  g_simple_action_set_state (action, state);
+}
+
 static gboolean
 get_idle (gpointer data)
 {
@@ -1621,6 +1640,7 @@ activate (GApplication *app)
   GtkCssProvider *provider;
   static GActionEntry win_entries[] = {
     { "dark", NULL, NULL, "false", change_theme_state },
+    { "transition", NULL, NULL, "false", change_transition_state },
     { "search", activate_search, NULL, NULL, NULL },
     { "delete", activate_delete, NULL, NULL, NULL },
     { "busy", get_busy, NULL, NULL, NULL },
@@ -1757,6 +1777,8 @@ activate (GApplication *app)
   g_signal_connect (stack, "notify::visible-child-name", G_CALLBACK (page_changed_cb), NULL);
   page_changed_cb (stack, NULL, NULL);
 
+  page_stack = stack;
+
   dialog = (GtkWidget *)gtk_builder_get_object (builder, "preference_dialog");
   g_signal_connect (dialog, "response", G_CALLBACK (close_dialog), NULL);
   widget = (GtkWidget *)gtk_builder_get_object (builder, "preference_dialog_button");
index 2cd966c283b566ab4226416635b447815b36de6e..42fedcb0155338a42b6f725591341393e167a7f4 100644 (file)
         <attribute name="label" translatable="yes">Dark Theme</attribute>
         <attribute name="action">win.dark</attribute>
       </item>
+      <item>
+        <attribute name="label" translatable="yes">Slide Pages</attribute>
+        <attribute name="action">win.transition</attribute>
+      </item>
     </section>
   </menu>
   <menu id="dinner_menu">
@@ -433,7 +437,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
           <object class="GtkStack" id="toplevel_stack">
             <property name="visible">1</property>
             <property name="transition-duration">1000</property>
-            <property name="transition-type">slide-left-right</property>
             <child>
               <object class="GtkBox" id="page1">
                 <property name="visible">1</property>